import { Meta, ArgsTable, Canvas, Story, Markdown } from '@storybook/addon-docs';
import { useArgs } from '@storybook/client-api';
import { Tabs } from '@zendeskgarden/react-tabs';
import { TabsStory } from './stories/TabsStory';
import { TABS } from './stories/data';
import README from '../README.md';

<Meta
  title="Packages/Tabs/Tabs"
  component={Tabs}
  subcomponents={{
    'Tabs.Tab': Tabs.Tab,
    'Tabs.TabList': Tabs.TabList,
    'Tabs.TabPanel': Tabs.TabPanel
  }}
  args={{ tabs: TABS }}
  argTypes={{ tabs: { table: { category: 'Story' } } }}
  parameters={{
    design: {
      allowFullscreen: true,
      type: 'figma',
      url: 'https://www.figma.com/file/6g87L4FdKZTA3knt3Rsfdx/Garden?node-id=102%3A123'
    }
  }}
/>

# API

<ArgsTable />

# Demo

## Uncontrolled

<Canvas>
  <Story name="Uncontrolled" argTypes={{ selectedItem: { control: false } }}>
    {args => <TabsStory {...args} />}
  </Story>
</Canvas>

## Controlled

<Canvas>
  <Story name="Controlled">
    {args => {
      const updateArgs = useArgs()[1];
      const handleChange = selectedItem => updateArgs({ selectedItem });
      return <TabsStory {...args} onChange={handleChange} />;
    }}
  </Story>
</Canvas>

<Markdown>{README}</Markdown>
